﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Xml.Linq;
using System.Xml;
using System.Xml.XPath;

namespace WW.Redirect
{
    public class GetRedirectUrlXml : WW.Redirect.Interfaces.IGetRedirectUrl    
    {
        public string getRedirectUrl(string lookupCode, WW.Redirect.Interfaces.IConfig configSettings)
        {
            string xpath = configSettings.Get("XPath");
            xpath = xpath.Replace("%code%", lookupCode);
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(configSettings.Get("PathToXmlDocument"));
            string value = xmlDoc.SelectSingleNode(xpath).Value;

            return value;
        }
    }
}
